import request from "@/api/index.js"

// 获取文章详情
export function getArticleContentApi(id) {
  return request({
    url: `/IntactArticle/details/${id}`,
    method: "get",
  })
}

// 获取评论列表
export function getComment(articleId, page = 1, parentId = null) {
  let parentIdStr = parentId != null ? `&parentId=${parentId}` : ''
  return request({
    url: `/comment?articleId=${articleId}&page=${page}` + parentIdStr,
    method: "get",
  })
}
// 用户关注
export function postUserFollowApi(uid) {
  return request({
    url: `/fans/addFollow?followUserId=${uid}`,
    method: "post",
  })
}
// 发送评论
export function postSendCommentApi(content = '', articleId = '', parentId = '0') {
  return request({
    url: `/comment`,
    method: "post",
    data: {
      "content": content,
      "parentId": parentId,
      "articleId": articleId,
      "link": ""
    }
  })
}

// 删除评论
export function deleteReplyApi(e) {
  return request({
    url: `/comment/${e}`,
    method: "delete",
  })
}

// 文章点赞
export function postArticleThumbsUpApi(id) {
  return request({
    url: `/article-like/${id}`,
    method: "post"
  })
}

// 评论点赞
export function postreplyThumbsUpApi(commentId) {
  return request({
    url: `/comment-like?commentId=${commentId}`,
    method: "post"
  })
}

// 转发
export function addShare(article_id) {
  return request({
    url: `/share/addShare`,
    method: "post",
    data: {
      articleId: article_id
    }
  })
}